Proper scope propagation for JS switch statements#500
Proper scope propagation for JS switch statements#500Lexxxzy wants to merge 1 commit intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses scope propagation issues in JavaScript switch statements by ensuring that variable references in case values can properly access variables from outer scopes. The fix modifies the tree-sitter stack graph rules to properly handle scope flow through case values when they contain no statements.
- Fixed scope propagation for empty switch cases to flow through case values
- Updated test expectations to reflect improved variable resolution
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/stack-graphs.tsg | Modified switch case handling to properly propagate scope through case values when no statements are present |
| test/statements/switch_statement.js | Added test cases for empty switch cases and updated expected variable definition locations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| (_)* @stmts)@switch_case { | ||
| if (is-empty @stmts) { | ||
| edge @switch_case.after_scope -> @switch_case.before_scope | ||
| ; scopes flow into the value and then directly out of the case |
There was a problem hiding this comment.
The comment uses a semicolon instead of the proper comment syntax. Should use '//' for comments in TSG files.
| ; scopes flow into the value and then directly out of the case | |
| // scopes flow into the value and then directly out of the case |
|
The github/stack-graphs repository is no longer being maintained. As per #502, I'm closing all issues and pull requests before archiving the repository. |
Address #499